//
//  JDSettlementTableViewCell.swift
//  DragonWallet
//
//  Created by volantPig on 2024/5/11.
//

import UIKit
/// 结算 cell
class JDSettlementTableViewCell: UITableViewCell {

    
    var buyerInfoModel: JDAuthenticationListModel?
    
    var goodsCount: Int = 0
    var containerViewOne: UIView?
    var storeNameLabel: UILabel?
    var goodsInfoTableView: UITableView?
//    var goodsInfoView: JDOrderGoodsView?
    
    var containerViewTwo: UIView?
    /// 关税金额
    var guanshuiPrice: JDCellInfoCellSubView?
    /// 境内物流费
    var jingneiwuliuPrice: JDCellInfoCellSubView?
    /// 跨境物流费
    var kuajingwuliuPrice: JDCellInfoCellSubView?
    
    var containerViewThree: UIView?
    /// 跨境订单号
    var orderId: JDCellInfoCellSubView?
    /// 供应商编号
    var gongyingshangNum: JDCellInfoCellSubView?
    
    var containerViewFour: UIView?
    var phoneTitleLabel: UILabel?
    var callButton: UIButton?
    
    var inputContainerViewTitle: UILabel?
    var inputContainerView: UIView?
    var authenticationRightArrow: UIImageView?
    
    
    var shopperNameInputView: UITextField?
    var shopperIDNumberInputView: UITextField?
    var shopperMessageInputView: UITextView?
    
    var addressInfoViewTitle: UILabel?
    var addressInfoContainerView: UIView?
    
    var shopperNameLabel: UILabel?
    var shopperTelLabel: UILabel?
    var shopperAddressLabel: UILabel?
    var changeAddressButton: UIButton?
    
//    var addAddressButton: UIButton?
    
    var tipsViewTitle: UILabel?
    var tipsContainerView: UIView?
    var tipsLabel: UILabel?
    
    var selectedShopCartModel: JDShopCartModel?
    var preOrderModel: JDPreOrderModel?
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.contentView.backgroundColor = color("#F5F6F8")
//        self.setupUIElements()
    }
    
    func setupUIElements() {
        self.createContainerViewOne()
        self.createContainerViewTwo()
//        self.createContainerViewThree()
        self.createContainerViewFour()
        self.newBuyerInfoView()
//        self.createInputContainerSubView()
        self.createNewAddressInfoView()
//        self.createAddressInfoView()
        self.createTipsView()
    }
    
    func createContainerViewOne() {
        
        self.containerViewOne = UIView()
        self.contentView.addSubview(self.containerViewOne!)
        self.containerViewOne?.snp.makeConstraints({ make in
            make.left.equalTo(self.contentView).offset(12)
            make.right.equalTo(self.contentView).offset(-12)
            make.top.equalTo(self.contentView)
        })
        self.containerViewOne?.backgroundColor = .white
        self.containerViewOne?.makeCorner(8)
        
        let line = UIView()
        self.containerViewOne?.addSubview(line)
        line.snp.makeConstraints { make in
            make.left.equalTo(self.containerViewOne!).offset(12)
            make.right.equalTo(self.containerViewOne!).offset(-12)
            make.top.equalTo(self.containerViewOne!).offset(52)
            make.height.equalTo(1)
        }
        line.backgroundColor = color("#F5F6F8")
        
        self.storeNameLabel = UILabel()
        self.containerViewOne?.addSubview(self.storeNameLabel!)
        self.storeNameLabel?.snp.makeConstraints({ make in
            make.left.equalTo(self.containerViewOne!).offset(12)
            make.top.equalTo(self.containerViewOne!)
            make.bottom.equalTo(line.snp.top)
        })
        self.storeNameLabel?.text = ""
        self.storeNameLabel?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 16, weight: .semibold), textColor: color("#333333"))
        
        
        self.goodsInfoTableView = UITableView.init(frame: .zero, style: .plain)
        self.containerViewOne?.addSubview(self.goodsInfoTableView!)
        self.goodsInfoTableView?.snp.makeConstraints({ make in
            make.left.equalTo(self.containerViewOne!)
            make.right.equalTo(self.containerViewOne!)
            make.top.equalTo(line.snp.bottom)
//            make.height.equalTo(104*1)
            make.height.equalTo(104*self.goodsCount)
            make.bottom.equalTo(self.containerViewOne!)
        })
        self.goodsInfoTableView?.delegate = self
        self.goodsInfoTableView?.dataSource = self
        self.goodsInfoTableView?.register(UITableViewCell.self, forCellReuseIdentifier: "goodsCell")
        self.goodsInfoTableView?.separatorStyle = .none
        
//        self.goodsInfoView = JDOrderGoodsView()
//        self.containerViewOne?.addSubview(self.goodsInfoView!)
//        self.goodsInfoView?.snp.makeConstraints({ make in
//            make.left.equalTo(self.containerViewOne!)
//            make.right.equalTo(self.containerViewOne!)
//            make.height.equalTo(104)
//            make.top.equalTo(line.snp.bottom)
//            make.bottom.equalTo(self.containerViewOne!)
//        })
        
    }
    
    func createContainerViewTwo() {
        
        self.containerViewTwo = UIView()
        self.contentView.addSubview(self.containerViewTwo!)
        self.containerViewTwo?.snp.makeConstraints({ make in
            make.left.equalTo(self.contentView).offset(12)
            make.right.equalTo(self.contentView).offset(-12)
            make.top.equalTo(self.containerViewOne!.snp.bottom).offset(11)
        })
        self.containerViewTwo?.backgroundColor = .white
        self.containerViewTwo?.layer.cornerRadius = 8
        
        self.guanshuiPrice = JDCellInfoCellSubView()
        self.containerViewTwo?.addSubview(self.guanshuiPrice!)
        self.guanshuiPrice?.snp.makeConstraints({ make in
            make.left.equalTo(self.containerViewTwo!)
            make.right.equalTo(self.containerViewTwo!)
            make.top.equalTo(self.containerViewTwo!).offset(9)
            make.height.equalTo(32)
        })
   
//        self.jingneiwuliuPrice = JDCellInfoCellSubView()
//        self.containerViewTwo?.addSubview(self.jingneiwuliuPrice!)
//        self.jingneiwuliuPrice?.snp.makeConstraints({ make in
//            make.left.equalTo(self.containerViewTwo!)
//            make.right.equalTo(self.containerViewTwo!)
//            make.top.equalTo(self.guanshuiPrice!.snp.bottom)
//            make.height.equalTo(32)
//        })
        
        self.kuajingwuliuPrice = JDCellInfoCellSubView()
        self.containerViewTwo?.addSubview(self.kuajingwuliuPrice!)
        self.kuajingwuliuPrice?.snp.makeConstraints({ make in
            make.left.equalTo(self.containerViewTwo!)
            make.right.equalTo(self.containerViewTwo!)
//            make.top.equalTo(self.jingneiwuliuPrice!.snp.bottom)
            make.top.equalTo(self.guanshuiPrice!.snp.bottom)
            make.height.equalTo(32)
            make.bottom.equalTo(self.containerViewTwo!.snp.bottom).offset(-9)
        })
        self.kuajingwuliuPrice?.titleLabel?.text = "跨境物流费"

    }
    
    // MARK: 这一项 现在是不要的
    func createContainerViewThree() {
        
        self.containerViewThree = UIView()
        self.contentView.addSubview(self.containerViewThree!)
        self.containerViewThree?.snp.makeConstraints({ make in
            make.left.equalTo(self.contentView).offset(12)
            make.right.equalTo(self.contentView).offset(-12)
            make.top.equalTo(self.containerViewTwo!.snp.bottom).offset(10)
        })
        self.containerViewThree?.backgroundColor = .white
        self.containerViewThree?.layer.cornerRadius = 8
        
        self.orderId = JDCellInfoCellSubView()
        self.containerViewThree?.addSubview(self.orderId!)
        self.orderId?.snp.makeConstraints({ make in
            make.left.equalTo(self.containerViewThree!)
            make.right.equalTo(self.containerViewThree!)
            make.top.equalTo(self.containerViewThree!).offset(9)
            make.height.equalTo(32)
            make.bottom.equalTo(self.containerViewThree!).offset(-9)
        })
        self.orderId?.titleLabel?.text = "跨境订单号"
        
//        self.gongyingshangNum = JDCellInfoCellSubView()
//        self.containerViewThree?.addSubview(self.gongyingshangNum!)
//        self.gongyingshangNum?.snp.makeConstraints({ make in
//            make.left.equalTo(self.containerViewThree!)
//            make.right.equalTo(self.containerViewThree!)
//            make.top.equalTo(self.orderId!.snp.bottom)
//            make.height.equalTo(32)
//            make.bottom.equalTo(self.containerViewThree!).offset(-9)
//        })
//        self.gongyingshangNum?.titleLabel?.text = "供应商编号"
    }
    
    func createContainerViewFour() {
        
        self.containerViewFour = UIView()
        self.contentView.addSubview(self.containerViewFour!)
        self.containerViewFour?.snp.makeConstraints({ make in
            make.left.equalTo(self.contentView).offset(12)
            make.right.equalTo(self.contentView).offset(-12)
            make.top.equalTo(self.containerViewTwo!.snp.bottom).offset(10)
//            make.top.equalTo(self.containerViewThree!.snp.bottom).offset(10)
            make.height.equalTo(50)
        })
        self.containerViewFour?.backgroundColor = .white
        self.containerViewFour?.layer.cornerRadius = 8
        
        self.phoneTitleLabel = UILabel()
        self.containerViewFour?.addSubview(self.phoneTitleLabel!)
        self.phoneTitleLabel?.snp.makeConstraints({ make in
            make.left.equalTo(self.containerViewFour!).offset(12)
            make.top.bottom.equalTo(self.containerViewFour!)
        })
        self.phoneTitleLabel?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 14, weight: .regular), textColor: color("#8D9198"))
        self.phoneTitleLabel?.text = "客服电话：0411-87979988"
    
        self.callButton = UIButton(type: .custom)
        self.containerViewFour?.addSubview(self.callButton!)
        self.callButton?.snp.makeConstraints({ make in
            make.right.equalTo(self.containerViewFour!).offset(-12)
            make.centerY.equalTo(self.containerViewFour!)
            make.size.equalTo(CGSize(width: 28, height: 28))
        })
        self.callButton?.setImage(UIImage(named: "call_image")?.withRenderingMode(.alwaysOriginal), for: .normal)
        self.callButton?.addTarget(self, action: #selector(callAuthorAction), for: .touchUpInside)
    }
    
    @objc func callAuthorAction() {
        let callStr = String.init(format: "tel:%@", self.preOrderModel?.customServicePhone ?? "")
        if let callUrl = URL(string: callStr) {
            UIApplication.shared.open(callUrl, options: [:]) { isSuccess in
            }
        }
    }
    
    var unRealNameLabel: UILabel?
    var unAuthenImageV: UIImageView?
    var realNameLabel: UILabel?
    var authenticationImageV: UIImageView?
    var buyerIdCard: UILabel?
    var hintLabel: JDPaddingLabel?
    var changeBuyerInfoButton: UIButton?
    
    func newBuyerInfoView() {
        
        self.inputContainerViewTitle = UILabel()
        self.contentView.addSubview(self.inputContainerViewTitle!)
        self.inputContainerViewTitle?.snp.makeConstraints({ make in
            make.left.equalTo(self.contentView).offset(24)
            make.top.equalTo(self.containerViewFour!.snp.bottom).offset(22)
            make.height.equalTo(22)
        })
        self.inputContainerViewTitle?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 16, weight: .semibold), textColor: color("#333333"))
        self.inputContainerViewTitle?.text = "购买人信息"
        
        let inputImgV = UIImageView()
        self.contentView.addSubview(inputImgV)
        inputImgV.snp.makeConstraints { make in
            make.left.equalTo(self.inputContainerViewTitle!.snp.right).offset(6)
            make.centerY.equalTo(self.inputContainerViewTitle!)
            make.size.equalTo(CGSizeMake(14, 14))
        }
        inputImgV.image = UIImage(named: "write_image")?.withRenderingMode(.alwaysOriginal)
        
        self.inputContainerView = UIView()
        self.contentView.addSubview(self.inputContainerView!)
        self.inputContainerView?.snp.makeConstraints({ make in
            make.left.equalTo(self.contentView).offset(12)
            make.right.equalTo(self.contentView).offset(-12)
            make.top.equalTo(self.inputContainerViewTitle!.snp.bottom).offset(14)
            make.height.greaterThanOrEqualTo(50)
        })
        self.inputContainerView?.layer.cornerRadius = 8
        self.inputContainerView?.backgroundColor = .white
        
        self.unRealNameLabel = UILabel()
        self.inputContainerView?.addSubview(self.unRealNameLabel!)
        self.unRealNameLabel?.snp.makeConstraints({ make in
            make.left.equalTo(self.inputContainerView!).offset(12)
//            make.top.equalTo(self.inputContainerView!).offset(15)
//            make.bottom.equalTo(self.inputContainerView!).offset(-15)
            make.centerY.equalTo(self.inputContainerView!)
        })
        self.unRealNameLabel?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 14, weight: .regular), textColor: color("#333333"), numberOfLines: 1)
        self.unRealNameLabel?.text = "选择实名认证"
        
        self.unAuthenImageV = UIImageView()
        self.inputContainerView?.addSubview(self.unAuthenImageV!)
        self.unAuthenImageV?.snp.makeConstraints { make in
            make.centerY.equalTo(self.unRealNameLabel!)
            make.right.equalTo(self.inputContainerView!).offset(-12)
        }
        self.unAuthenImageV?.image = UIImage(named: "arrow_right")?.withRenderingMode(.alwaysOriginal)
        
        self.realNameLabel = UILabel()
        self.inputContainerView?.addSubview(self.realNameLabel!)
        self.realNameLabel?.snp.makeConstraints({ make in
            make.left.equalTo(self.inputContainerView!).offset(12)
            make.top.equalTo(self.inputContainerView!).offset(20)
            make.height.equalTo(22)
        })
        self.realNameLabel?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 16, weight: .regular), textColor: color("#333333"), numberOfLines: 1)
//        self.realNameLabel?.text = "刘德华"
        
        self.authenticationImageV = UIImageView()
        self.inputContainerView?.addSubview(self.authenticationImageV!)
        self.authenticationImageV?.snp.makeConstraints({ make in
            make.left.equalTo(self.realNameLabel!.snp.right).offset(6)
            make.centerY.equalTo(self.realNameLabel!)
            make.size.equalTo(CGSizeMake(50, 16))
        })
        self.authenticationImageV?.image = UIImage(named: "authentication_ok")?.withRenderingMode(.alwaysOriginal)
        
        authenticationRightArrow = UIImageView()
        self.inputContainerView?.addSubview(self.authenticationRightArrow!)
        self.authenticationRightArrow?.snp.makeConstraints { make in
            make.right.equalTo(self.inputContainerView!).offset(-11)
//            make.centerY.equalTo(self.inputContainerView!)
            make.centerY.equalTo(self.realNameLabel!.snp.bottom).offset(2)
            make.size.equalTo(CGSizeMake(7, 11))
        }
        self.authenticationRightArrow?.image = UIImage(named: "arrow_right")?.withRenderingMode(.alwaysOriginal)
        
        
        self.buyerIdCard = UILabel()
        self.inputContainerView?.addSubview(self.buyerIdCard!)
        self.buyerIdCard?.snp.makeConstraints({ make in
            make.left.equalTo(self.inputContainerView!).offset(12)
            make.top.equalTo(self.realNameLabel!.snp.bottom).offset(4)
            make.height.equalTo(20)
//            make.bottom.equalTo(self.inputContainerView!).offset(-16)
        })
        self.buyerIdCard?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 14, weight: .regular), textColor: color("#8D9198"), numberOfLines: 1)
//        self.buyerIdCard?.text = "210802111010101112"
        
        self.hintLabel = JDPaddingLabel()
        self.inputContainerView?.addSubview(self.hintLabel!)
        self.hintLabel?.snp.makeConstraints({ make in
            make.left.equalTo(self.inputContainerView!).offset(12)
            make.right.equalTo(self.inputContainerView!).offset(-12)
            make.top.equalTo(self.buyerIdCard!.snp.bottom).offset(16)
            make.bottom.equalTo(self.inputContainerView!).offset(-16)
        })
        self.hintLabel?.edgeInsets = .init(top: 10, left: 10, bottom: 10, right: 10)
        self.hintLabel?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 12, weight: .regular), textColor: color("#8D9198"),numberOfLines: 0)
        self.hintLabel?.text = "提示:海关会与实名认证的用户进行电话回访确认商品信息，如若实名信息有误，无法继续通关，造成的损失，平台不予承担。"
        self.hintLabel?.backgroundColor = color("#F5F6F8")
        self.hintLabel?.makeCorner(8)
        
        
        self.changeBuyerInfoButton = UIButton(type: .custom)
        self.inputContainerView?.addSubview(self.changeBuyerInfoButton!)
        self.changeBuyerInfoButton?.snp.makeConstraints { make in
            make.left.right.top.bottom.equalTo(self.inputContainerView!)
        }
//        self.changeBuyerInfoButton?.backgroundColor = .red.withAlphaComponent(0.2)
        
    }
    
    /// 更新 认证信息
    func uploadAuthenticationInfo(_ hasAuthenticationInfo: Bool = false ) {
        
        self.unRealNameLabel?.snp.removeConstraints()
        self.unAuthenImageV?.snp.removeConstraints()
        
        self.realNameLabel?.snp.removeConstraints()
        self.authenticationImageV?.snp.removeConstraints()
        self.buyerIdCard?.snp.removeConstraints()
        self.hintLabel?.snp.removeConstraints()
        self.changeBuyerInfoButton?.snp.removeConstraints()
        

        if hasAuthenticationInfo {
            self.unRealNameLabel?.isHidden = true
            self.unAuthenImageV?.isHidden = true
            
            self.realNameLabel?.isHidden = false
            self.authenticationImageV?.isHidden = false
            self.buyerIdCard?.isHidden = false
//            self.changeBuyerInfoButton?.isHidden = false
            self.authenticationRightArrow?.isHidden = false
            
            
            self.realNameLabel?.snp.makeConstraints({ make in
                make.left.equalTo(self.inputContainerView!).offset(12)
                make.top.equalTo(self.inputContainerView!).offset(20)
                make.height.equalTo(22)
            })
            
            self.authenticationImageV?.snp.makeConstraints({ make in
                make.left.equalTo(self.realNameLabel!.snp.right).offset(6)
                make.centerY.equalTo(self.realNameLabel!)
                make.size.equalTo(CGSizeMake(50, 16))
            })
            
            self.buyerIdCard?.snp.makeConstraints({ make in
                make.left.equalTo(self.inputContainerView!).offset(12)
                make.top.equalTo(self.realNameLabel!.snp.bottom).offset(4)
                make.height.equalTo(20)
//                make.bottom.equalTo(self.inputContainerView!).offset(-16)
            })
            
            self.hintLabel?.snp.makeConstraints({ make in
                make.left.equalTo(self.inputContainerView!).offset(12)
                make.right.equalTo(self.inputContainerView!).offset(-12)
                make.top.equalTo(self.buyerIdCard!.snp.bottom).offset(16)
                make.bottom.equalTo(self.inputContainerView!).offset(-16)
            })
            
            self.changeBuyerInfoButton?.snp.makeConstraints { make in
                make.left.right.top.bottom.equalTo(self.inputContainerView!)
            }
        } else {
            self.unRealNameLabel?.isHidden = false
            
            self.realNameLabel?.isHidden = true
            self.authenticationImageV?.isHidden = true
            self.buyerIdCard?.isHidden = true
            self.hintLabel?.isHidden = true
//            self.changeBuyerInfoButton?.isHidden = true
            self.authenticationRightArrow?.isHidden = true

            self.unRealNameLabel?.snp.makeConstraints({ make in
                make.left.equalTo(self.inputContainerView!).offset(12)
                make.centerY.equalTo(self.inputContainerView!)
            })
            
            self.unAuthenImageV?.snp.makeConstraints { make in
                make.centerY.equalTo(self.unRealNameLabel!)
                make.right.equalTo(self.inputContainerView!).offset(-12)
            }
            
            self.changeBuyerInfoButton?.snp.makeConstraints { make in
                make.left.right.top.bottom.equalTo(self.inputContainerView!)
            }
        }
        self.inputContainerView?.layoutIfNeeded()
    }
    
    func createInputContainerSubView() {
        
        self.inputContainerViewTitle = UILabel()
        self.contentView.addSubview(self.inputContainerViewTitle!)
        self.inputContainerViewTitle?.snp.makeConstraints({ make in
            make.left.equalTo(self.contentView).offset(24)
            make.top.equalTo(self.containerViewFour!.snp.bottom).offset(22)
            make.height.equalTo(22)
        })
        self.inputContainerViewTitle?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 16, weight: .semibold), textColor: color("#333333"))
        self.inputContainerViewTitle?.text = "填写购买人信息"
        
        let inputImgV = UIImageView()
        self.contentView.addSubview(inputImgV)
        inputImgV.snp.makeConstraints { make in
            make.left.equalTo(self.inputContainerViewTitle!.snp.right).offset(6)
            make.centerY.equalTo(self.inputContainerViewTitle!)
            make.size.equalTo(CGSizeMake(14, 14))
        }
        inputImgV.image = UIImage(named: "write_image")?.withRenderingMode(.alwaysOriginal)
        
        self.inputContainerView = UIView()
        self.contentView.addSubview(self.inputContainerView!)
        self.inputContainerView?.snp.makeConstraints({ make in
            make.left.equalTo(self.contentView).offset(12)
            make.right.equalTo(self.contentView).offset(-12)
            make.top.equalTo(self.inputContainerViewTitle!.snp.bottom).offset(14)
        })
        self.inputContainerView?.layer.cornerRadius = 8
        self.inputContainerView?.backgroundColor = .white
        
        let topLine = UIView()
        self.inputContainerView?.addSubview(topLine)
        topLine.snp.makeConstraints { make in
            make.left.equalTo(self.inputContainerView!).offset(12)
            make.right.equalTo(self.inputContainerView!).offset(-12)
            make.top.equalTo(self.inputContainerView!).offset(55)
            make.height.equalTo(0.5)
        }
        topLine.backgroundColor = color("#EDEEF1")
        
        let nameTitle = UILabel()
        self.inputContainerView?.addSubview(nameTitle)
        nameTitle.snp.makeConstraints { make in
            make.top.equalTo(self.inputContainerView!)
            make.bottom.equalTo(topLine.snp.top)
            make.left.equalTo(self.inputContainerView!).offset(12)
        }
        nameTitle.text = "真实姓名 "
        nameTitle.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 14, weight: .regular), textColor: color("#333333"))
        nameTitle.appendAttributedString(appenStr: "*", attrs: [.foregroundColor: color("#FA6161"),.font: UIFont.systemFont(ofSize: 14, weight: .regular)])
        
        self.shopperNameInputView = UITextField()
        self.inputContainerView?.addSubview(self.shopperNameInputView!)
        self.shopperNameInputView?.snp.makeConstraints({ make in
            make.left.equalTo(self.inputContainerView!).offset(90)
//            make.left.equalTo(nameTitle.snp.right).offset(12)
            make.right.equalTo(self.inputContainerView!).offset(-12)
            make.top.equalTo(self.inputContainerView!)
            make.bottom.equalTo(topLine.snp.top)
        })
        self.shopperNameInputView?.textColor = color("#333333")
        self.shopperNameInputView?.font = UIFont.systemFont(ofSize: 14, weight: .regular)
        self.shopperNameInputView?.placeholder = "购买人真实姓名"
        self.shopperNameInputView?.textAlignment = .right
        
        let middleLine = UIView()
        self.inputContainerView?.addSubview(middleLine)
        middleLine.snp.makeConstraints { make in
            make.left.equalTo(self.inputContainerView!).offset(12)
            make.right.equalTo(self.inputContainerView!).offset(-12)
            make.top.equalTo(topLine.snp.bottom).offset(60)
            make.height.equalTo(0.5)
            make.bottom.equalTo(inputContainerView!)
        }
        middleLine.backgroundColor = color("#EDEEF1")
        middleLine.isHidden = true
        
        let idCardTitle = UILabel()
        self.inputContainerView?.addSubview(idCardTitle)
        idCardTitle.snp.makeConstraints { make in
            make.left.equalTo(self.inputContainerView!).offset(12)
            make.top.equalTo(topLine.snp.bottom)
            make.bottom.equalTo(middleLine.snp.top)
        }
        idCardTitle.text = "身份证号 "
        idCardTitle.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 14, weight: .regular), textColor: color("#333333"))
        idCardTitle.appendAttributedString(appenStr: "*", attrs: [.foregroundColor: color("#FA6161"),.font: UIFont.systemFont(ofSize: 14, weight: .regular)])
        idCardTitle.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
        
        self.shopperIDNumberInputView = UITextField()
        self.inputContainerView?.addSubview(self.shopperIDNumberInputView!)
        self.shopperIDNumberInputView?.snp.makeConstraints({ make in
//            make.left.equalTo(self.inputContainerView!).offset(12)
            make.left.equalTo(self.shopperNameInputView!)
            make.top.equalTo(topLine.snp.bottom)
            make.bottom.equalTo(middleLine.snp.top)
            make.right.equalTo(self.inputContainerView!).offset(-12)
        })
        self.shopperIDNumberInputView?.placeholder = "购买人身份证号"
        self.shopperIDNumberInputView?.textColor = color("#333333")
        self.shopperIDNumberInputView?.font = UIFont.systemFont(ofSize: 14, weight: .regular)
        self.shopperIDNumberInputView?.textAlignment = .right
//        self.shopperIDNumberInputView?.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
        
//        let msgTitle = UILabel()
//        self.inputContainerView?.addSubview(msgTitle)
//        msgTitle.snp.makeConstraints { make in
//            make.left.equalTo(self.inputContainerView!).offset(12)
//            make.top.equalTo(middleLine.snp.bottom).offset(20)
//            make.height.equalTo(20)
//        }
//        msgTitle.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 14, weight: .regular), textColor: color("#8D9198"))
        
        return;
        
        self.shopperMessageInputView = UITextView()
        self.inputContainerView?.addSubview(self.shopperMessageInputView!)
        self.shopperMessageInputView?.snp.makeConstraints({ make in
            make.left.equalTo(self.inputContainerView!).offset(12)
            make.right.equalTo(self.inputContainerView!).offset(-12)
            make.top.equalTo(middleLine.snp.bottom)//.offset(20)
            make.height.equalTo(70)
            make.bottom.equalTo(self.inputContainerView!).offset(-15)
        })
        self.shopperMessageInputView?.placeholder = "用户留言"
//        self.shopperMessageInputView?.placeholderColor =
        self.shopperMessageInputView?.textColor = color("#333333")
        self.shopperMessageInputView?.font = UIFont.systemFont(ofSize: 14, weight: .regular)
    }
    
    var unAddressLabel: UILabel?
    /// 完善地址
    var improveAddressButton: UIButton?
    var addressrRightArrow: UIImageView?
    
    func createNewAddressInfoView() {
        
        self.addressInfoViewTitle = UILabel()
        self.contentView.addSubview(self.addressInfoViewTitle!)
        self.addressInfoViewTitle?.snp.makeConstraints({ make in
            make.left.equalTo(self.contentView).offset(24)
            make.top.equalTo(self.inputContainerView!.snp.bottom).offset(22)
            make.height.equalTo(22)
        })
        self.addressInfoViewTitle?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 16, weight: .semibold), textColor: color("#333333"))
        self.addressInfoViewTitle?.text = "收货信息"
        
        let addressImgV = UIImageView()
        self.contentView.addSubview(addressImgV)
        addressImgV.snp.makeConstraints { make in
            make.left.equalTo(self.addressInfoViewTitle!.snp.right).offset(6)
            make.size.equalTo(CGSize(width: 14, height: 14))
            make.centerY.equalTo(self.addressInfoViewTitle!)
        }
        addressImgV.image = UIImage(named: "location")?.withRenderingMode(.alwaysOriginal)
        
        self.addressInfoContainerView = UIView()
        self.contentView.addSubview(self.addressInfoContainerView!)
        self.addressInfoContainerView?.snp.makeConstraints({ make in
            make.left.equalTo(self.contentView).offset(12)
            make.right.equalTo(self.contentView).offset(-12)
            make.top.equalTo(self.addressInfoViewTitle!.snp.bottom).offset(14)
            make.height.greaterThanOrEqualTo(50)
        })
        self.addressInfoContainerView?.backgroundColor = .white
        self.addressInfoContainerView?.layer.cornerRadius = 8
     
        self.addressrRightArrow = UIImageView()
        self.addressInfoContainerView?.addSubview(self.addressrRightArrow!)
        self.addressrRightArrow?.snp.makeConstraints { make in
            make.right.equalTo(self.addressInfoContainerView!).offset(-11)
            make.centerY.equalTo(self.addressInfoContainerView!)
            make.size.equalTo(CGSizeMake(7, 11))
        }
        self.addressrRightArrow?.image = UIImage(named: "arrow_right")?.withRenderingMode(.alwaysOriginal)
        
        self.unAddressLabel = UILabel()
        self.addressInfoContainerView?.addSubview(self.unAddressLabel!)
        self.unAddressLabel?.snp.makeConstraints({ make in
            make.left.equalTo(self.addressInfoContainerView!).offset(12)
            make.centerY.equalTo(self.addressInfoContainerView!)
        })
        self.unAddressLabel?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 14, weight: .regular), textColor: color("#333333"), numberOfLines: 1)
        self.unAddressLabel?.text = "完善收货信息"
        
        self.improveAddressButton = UIButton(type: .custom)
        self.addressInfoContainerView?.addSubview(self.improveAddressButton!)
        self.improveAddressButton?.snp.makeConstraints { make in
            make.left.right.top.bottom.equalTo(self.addressInfoContainerView!)
        }
        
        
        self.shopperNameLabel = UILabel()
        self.addressInfoContainerView?.addSubview(self.shopperNameLabel!)
        self.shopperNameLabel?.snp.makeConstraints({ make in
            make.left.equalTo(self.addressInfoContainerView!).offset(12)
            make.top.equalTo(self.addressInfoContainerView!).offset(16)
            make.height.equalTo(25)
        })
        self.shopperNameLabel?.text = "罗先生"
        self.shopperNameLabel?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 18, weight: .semibold), textColor: color("#333333"))
        
        self.shopperTelLabel = UILabel()
        self.addressInfoContainerView?.addSubview(self.shopperTelLabel!)
        self.shopperTelLabel?.snp.makeConstraints({ make in
            make.left.equalTo(self.addressInfoContainerView!).offset(12)
            make.top.equalTo(self.shopperNameLabel!.snp.bottom).offset(5)
            make.height.equalTo(20)
        })
        self.shopperTelLabel?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 14, weight: .regular), textColor: color("#333333"))
        self.shopperTelLabel?.text = "13644930209"
        
        self.shopperAddressLabel = UILabel()
        self.addressInfoContainerView?.addSubview(self.shopperAddressLabel!)
        self.shopperAddressLabel?.snp.makeConstraints({ make in
            make.left.equalTo(self.addressInfoContainerView!).offset(12)
            make.top.equalTo(self.shopperTelLabel!.snp.bottom).offset(5)
            make.height.equalTo(20)
            make.bottom.equalTo(self.addressInfoContainerView!).offset(-18)
        })
        self.shopperAddressLabel?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 14, weight: .regular), textColor: color("#333333"))
        self.shopperAddressLabel?.text = "辽宁省大连市甘井子区高云路136号2-1"
        
        self.changeAddressButton = UIButton(type: .custom)
        self.addressInfoContainerView?.addSubview(self.changeAddressButton!)
        self.changeAddressButton?.snp.makeConstraints({ make in
            make.right.equalTo(self.addressInfoContainerView!).offset(-12)
            make.centerY.equalTo(self.addressInfoContainerView!)
            make.size.equalTo(CGSize(width: 56, height: 32))
        })
        self.changeAddressButton?.layer.cornerRadius = 16
        self.changeAddressButton?.layer.borderWidth = 1
        self.changeAddressButton?.layer.borderColor = color("#333333").cgColor
        self.changeAddressButton?.setTitle("修改", for: .normal)
        self.changeAddressButton?.setTitleColor(color("#333333"), for: .normal)
        self.changeAddressButton?.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: .regular)
        
    }
    
//    func createAddressInfoView() {
//        
//        self.addressInfoViewTitle = UILabel()
//        self.contentView.addSubview(self.addressInfoViewTitle!)
//        self.addressInfoViewTitle?.snp.makeConstraints({ make in
//            make.left.equalTo(self.contentView).offset(24)
//            make.top.equalTo(self.inputContainerView!.snp.bottom).offset(22)
//            make.height.equalTo(22)
//        })
//        self.addressInfoViewTitle?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 16, weight: .semibold), textColor: color("#333333"))
//        self.addressInfoViewTitle?.text = "收货信息"
//        
//        let addressImgV = UIImageView()
//        self.contentView.addSubview(addressImgV)
//        addressImgV.snp.makeConstraints { make in
//            make.left.equalTo(self.addressInfoViewTitle!.snp.right).offset(6)
//            make.size.equalTo(CGSize(width: 14, height: 14))
//            make.centerY.equalTo(self.addressInfoViewTitle!)
//        }
//        addressImgV.image = UIImage(named: "location")?.withRenderingMode(.alwaysOriginal)
//        
//        self.addressInfoContainerView = UIView()
//        self.contentView.addSubview(self.addressInfoContainerView!)
//        self.addressInfoContainerView?.snp.makeConstraints({ make in
//            make.left.equalTo(self.contentView).offset(12)
//            make.right.equalTo(self.contentView).offset(-12)
//            make.top.equalTo(self.addressInfoViewTitle!.snp.bottom).offset(14)
//        })
//        self.addressInfoContainerView?.backgroundColor = .white
//        self.addressInfoContainerView?.layer.cornerRadius = 8
//        
//        self.shopperNameLabel = UILabel()
//        self.addressInfoContainerView?.addSubview(self.shopperNameLabel!)
//        self.shopperNameLabel?.snp.makeConstraints({ make in
//            make.left.equalTo(self.addressInfoContainerView!).offset(12)
//            make.top.equalTo(self.addressInfoContainerView!).offset(16)
//            make.height.equalTo(25)
//        })
//        self.shopperNameLabel?.text = "罗先生"
//        self.shopperNameLabel?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 18, weight: .semibold), textColor: color("#333333"))
//        
//        self.shopperTelLabel = UILabel()
//        self.addressInfoContainerView?.addSubview(self.shopperTelLabel!)
//        self.shopperTelLabel?.snp.makeConstraints({ make in
//            make.left.equalTo(self.addressInfoContainerView!).offset(12)
//            make.top.equalTo(self.shopperNameLabel!.snp.bottom).offset(5)
//            make.height.equalTo(20)
//        })
//        self.shopperTelLabel?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 14, weight: .regular), textColor: color("#333333"))
//        self.shopperTelLabel?.text = "13644930209"
//        
//        self.shopperAddressLabel = UILabel()
//        self.addressInfoContainerView?.addSubview(self.shopperAddressLabel!)
//        self.shopperAddressLabel?.snp.makeConstraints({ make in
//            make.left.equalTo(self.addressInfoContainerView!).offset(12)
//            make.top.equalTo(self.shopperTelLabel!.snp.bottom).offset(5)
//            make.height.equalTo(20)
//            make.bottom.equalTo(self.addressInfoContainerView!).offset(-18)
//        })
//        self.shopperAddressLabel?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 14, weight: .regular), textColor: color("#333333"))
//        self.shopperAddressLabel?.text = "辽宁省大连市甘井子区高云路136号2-1"
//        
//        self.changeAddressButton = UIButton(type: .custom)
//        self.addressInfoContainerView?.addSubview(self.changeAddressButton!)
//        self.changeAddressButton?.snp.makeConstraints({ make in
//            make.right.equalTo(self.addressInfoContainerView!).offset(-12)
//            make.centerY.equalTo(self.addressInfoContainerView!)
//            make.size.equalTo(CGSize(width: 56, height: 32))
//        })
//        self.changeAddressButton?.layer.cornerRadius = 16
//        self.changeAddressButton?.layer.borderWidth = 1
//        self.changeAddressButton?.layer.borderColor = color("#333333").cgColor
//        self.changeAddressButton?.setTitle("修改", for: .normal)
//        self.changeAddressButton?.setTitleColor(color("#333333"), for: .normal)
//        self.changeAddressButton?.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: .regular)
//        
//        // 与 上方的互斥
//        self.addAddressButton = UIButton(type: .custom)
//        self.addressInfoContainerView?.addSubview(self.addAddressButton!)
//        self.addAddressButton?.snp.makeConstraints({ make in
//            make.left.equalTo(self.addressInfoContainerView!).offset(35)
//            make.right.equalTo(self.addressInfoContainerView!).offset(-35)
//            make.height.equalTo(42)
//            make.centerY.equalTo(self.addressInfoContainerView!)
//        })
//        self.addAddressButton?.setTitle("完善收货信息", for: .normal)
//        self.addAddressButton?.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: .regular)
//        self.addAddressButton?.setTitleColor(color("#FA6161"), for: .normal)
//        self.addAddressButton?.makeCorner(21)
//        self.addAddressButton?.layer.borderWidth = 1
//        self.addAddressButton?.layer.borderColor = color("#FA6161").cgColor
//    }
    
    func createTipsView() {
        
        self.tipsViewTitle = UILabel()
        self.contentView.addSubview(self.tipsViewTitle!)
        self.tipsViewTitle?.snp.makeConstraints({ make in
            make.left.equalTo(self.contentView).offset(24)
            make.top.equalTo(self.addressInfoContainerView!.snp.bottom).offset(22)
            make.height.equalTo(22)
        })
        self.tipsViewTitle?.text = "平台提示"
        self.tipsViewTitle?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 16, weight: .semibold), textColor: color("#333333"))
        
        let hintImgV = UIImageView()
        self.contentView.addSubview(hintImgV)
        hintImgV.snp.makeConstraints { make in
            make.left.equalTo(self.tipsViewTitle!.snp.right).offset(6)
            make.centerY.equalTo(self.tipsViewTitle!)
            make.size.equalTo(CGSize(width: 11, height: 14))
        }
        hintImgV.image = UIImage(named: "hint")?.withRenderingMode(.alwaysOriginal)
        
        self.tipsContainerView = UIView()
        self.contentView.addSubview(self.tipsContainerView!)
        self.tipsContainerView?.snp.makeConstraints({ make in
            make.left.equalTo(self.contentView).offset(12)
            make.right.equalTo(self.contentView).offset(-12)
            make.top.equalTo(self.tipsViewTitle!.snp.bottom).offset(14)
            make.bottom.equalTo(self.contentView).offset(-25)
        })
        self.tipsContainerView?.layer.cornerRadius = 8
        self.tipsContainerView?.backgroundColor = color("#FFFDFA")
        
        self.tipsLabel = UILabel()
        self.tipsContainerView?.addSubview(self.tipsLabel!)
        self.tipsLabel?.snp.makeConstraints({ make in
            make.left.equalTo(self.tipsContainerView!).offset(12)
            make.right.equalTo(self.tipsContainerView!).offset(-12)
            make.top.equalTo(self.tipsContainerView!).offset(12)
            make.bottom.equalTo(self.tipsContainerView!).offset(-12)
        })
        self.tipsLabel?.text = "· 您所购商品是平台依照您的订单申办进口的，所以不能为您提供退货换货响应且可能被拒单，您下单后力争20天内送达；\n· 国内配送费由用户承担，待货品送达后，由用户向承运公司自行支付。\n· 购买跨境商品，平台接单后不接受取消订单或商品退换诉求。"
        self.tipsLabel?.addTextLineSpace(spaceHeight: 8)
        self.tipsLabel?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 14, weight: .regular), textColor: color("#333333"), numberOfLines: 0)
    }
    
    func reloadData() {
        
        for subView  in self.contentView.subviews {
            subView.removeFromSuperview()
        }
        
        var count = 0
        for subModel in self.selectedShopCartModel?.goodsList ?? [JDShopCartGoodsModel]() {
            if subModel.isSelected {
                count += 1
            }
        }
        self.goodsCount = count
        
        setupUIElements()
        
        self.storeNameLabel?.text = self.preOrderModel?.shopName ?? "未知商户"
        
        self.guanshuiPrice?.descriptionLabel?.text = String.init(format: "￥%@", self.preOrderModel?.totalTariffText ?? "0.00")
        self.kuajingwuliuPrice?.descriptionLabel?.text = String.init(format: "￥%@", self.preOrderModel?.totalFreightText ?? "0.00")
        
        self.orderId?.descriptionLabel?.text = self.preOrderModel?.preOrderId ?? ""
        self.gongyingshangNum?.descriptionLabel?.text = "尚无此数据"
        
        if (self.preOrderModel?.province?.count ?? 0) > 0 {
            self.shopperNameLabel?.text = self.preOrderModel?.receiverName
            self.shopperTelLabel?.text = String.init(format: "%@ · %@", self.preOrderModel?.mobile ?? "", self.preOrderModel?.postal ?? "116000")
            self.shopperAddressLabel?.text = String.init(format: "%@%@%@%@", self.preOrderModel?.province ?? "",self.preOrderModel?.city ?? "",self.preOrderModel?.district ?? "",self.preOrderModel?.address ?? "" )
//            self.addAddressButton?.isHidden = true
            self.shopperNameLabel?.isHidden = false
            self.shopperTelLabel?.isHidden = false
            self.shopperAddressLabel?.isHidden = false
            self.changeAddressButton?.isHidden = false
            
            self.unAddressLabel?.isHidden = true
            self.improveAddressButton?.isHidden = true
            self.addressrRightArrow?.isHidden = true
            
            self.uploadAddress(true)
            
        } else {
            self.shopperNameLabel?.isHidden = true
            self.shopperTelLabel?.isHidden = true
            self.shopperAddressLabel?.isHidden = true
            self.changeAddressButton?.isHidden = true
//            self.addAddressButton?.isHidden = false
            self.unAddressLabel?.isHidden = false
            self.improveAddressButton?.isHidden = false
            self.addressrRightArrow?.isHidden = false
            
            self.uploadAddress(false)
        }
        
        if self.buyerInfoModel == nil {
            self.uploadAuthenticationInfo()
        } else {
            self.uploadAuthenticationInfo(true)
            
            self.realNameLabel?.text = self.buyerInfoModel?.realName
            self.buyerIdCard?.text = self.buyerInfoModel?.idCardNo

            
        }
        self.phoneTitleLabel?.text = String(format: "客服电话：%@", self.preOrderModel?.customServicePhone ?? "")
        self.layoutSubviews()
        self.layoutIfNeeded()
        
    }
    /// 更新 收货信息
    func uploadAddress(_ hasAddress: Bool = false ) {
        
        self.shopperNameLabel?.snp.removeConstraints()
        self.shopperTelLabel?.snp.removeConstraints()
        self.shopperAddressLabel?.snp.removeConstraints()
        self.changeAddressButton?.snp.removeConstraints()
        self.unAddressLabel?.snp.removeConstraints()
        self.improveAddressButton?.snp.removeConstraints()
        
        if hasAddress {
            
            self.shopperNameLabel?.snp.makeConstraints({ make in
                make.left.equalTo(self.addressInfoContainerView!).offset(12)
                make.top.equalTo(self.addressInfoContainerView!).offset(16)
                make.height.equalTo(25)
            })
            self.shopperTelLabel?.snp.makeConstraints({ make in
                make.left.equalTo(self.addressInfoContainerView!).offset(12)
                make.top.equalTo(self.shopperNameLabel!.snp.bottom).offset(5)
                make.height.equalTo(20)
            })
            self.shopperAddressLabel?.snp.makeConstraints({ make in
                make.left.equalTo(self.addressInfoContainerView!).offset(12)
                make.top.equalTo(self.shopperTelLabel!.snp.bottom).offset(5)
                make.height.equalTo(20)
                make.bottom.equalTo(self.addressInfoContainerView!).offset(-18)
            })
            self.changeAddressButton?.snp.makeConstraints({ make in
                make.right.equalTo(self.addressInfoContainerView!).offset(-12)
                make.centerY.equalTo(self.addressInfoContainerView!)
                make.size.equalTo(CGSize(width: 56, height: 32))
            })
        } else {
            self.unAddressLabel?.snp.makeConstraints({ make in
                make.left.equalTo(self.addressInfoContainerView!).offset(12)
                make.centerY.equalTo(self.addressInfoContainerView!)
            })
            self.improveAddressButton?.snp.makeConstraints { make in
                make.left.right.top.bottom.equalTo(self.addressInfoContainerView!)
            }
        }
        self.addressInfoContainerView?.layoutIfNeeded()
       
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}



extension JDSettlementTableViewCell: UITableViewDelegate, UITableViewDataSource {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        
        var count = 0
        for subModel in self.selectedShopCartModel?.goodsList ?? [JDShopCartGoodsModel]() {
            if subModel.isSelected {
                count += 1
            }
        }
        return count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "goodsCell")
        
        var currentModel: JDShopCartGoodsModel?
        var subCount = 0
        for subGoodsModel in self.selectedShopCartModel?.goodsList ?? [JDShopCartGoodsModel]() {
            if subGoodsModel.isSelected {
                if subCount == indexPath.row {
                    currentModel = subGoodsModel
                    break
                }
                subCount += 1
            }
        }
        
        let goodsInfoView = JDOrderGoodsView()
        cell?.contentView.addSubview(goodsInfoView)
        goodsInfoView.snp.makeConstraints { make in
            make.height.equalTo(104)
            make.top.equalTo(cell!.contentView)
            make.left.equalTo(cell!.contentView)
            make.right.equalTo(cell!.contentView)
        }
        goodsInfoView.goodsName.text = currentModel?.goodsName
        goodsInfoView.goodsSpec.text = String.init(format: "规格：%@", currentModel?.specificationName ?? "")
        goodsInfoView.goodsNum.text = String.init(format: "数量：%zd", currentModel?.count ?? 0)
        goodsInfoView.goodsAddress.text = String.init(format: "产地：%@", currentModel?.origin ?? "")
        
        
        let totalPrice = Double((currentModel?.salePrice ?? 0) * (currentModel?.count ?? 0))/1000.0
        
        goodsInfoView.goodsPrice.text = String.init(format: "￥%.2f", totalPrice)
        goodsInfoView.goodsPrice.priceString(UIFont.systemFont(ofSize: 12, weight: .regular), UIFont.systemFont(ofSize: 16, weight: .semibold))
        
        if currentModel?.goodsMainImgUrl?.hasPrefix("http") ?? false  {
            goodsInfoView.goodsImgV.kf.setImage(with: URL(string: currentModel?.goodsMainImgUrl ?? ""),placeholder: UIImage(named: "loading_placeholder"))
        } else {
            goodsInfoView.goodsImgV.downloadImage(currentModel?.goodsMainImgUrl ?? "")
        }
        
        return cell!
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 104
    }
    
    
}


class JDCellInfoCellSubView: UIView {
    
    var titleLabel: UILabel?
    var descriptionLabel: UILabel?
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.setupUIElements()
    }
    
    func setupUIElements(){
        self.titleLabel = UILabel()
        self.addSubview(self.titleLabel!)
        self.titleLabel?.snp.makeConstraints({ make in
            make.left.equalTo(self).offset(12)
            make.top.equalTo(self)
            make.bottom.equalTo(self)
        })
        self.titleLabel?.labelConfig(textAlignment: .left, font: UIFont.systemFont(ofSize: 14, weight: .regular), textColor: color("#8D9198"), numberOfLines: 1)
        self.titleLabel?.text = "关税金额"
        
        self.descriptionLabel = UILabel()
        self.addSubview(self.descriptionLabel!)
        self.descriptionLabel?.snp.makeConstraints({ make in
            make.right.equalTo(self).offset(-12)
            make.top.equalTo(self)
            make.bottom.equalTo(self)
        })
        self.descriptionLabel?.labelConfig(textAlignment: .right, font: UIFont.systemFont(ofSize: 14, weight: .regular), textColor: color("#333333"), numberOfLines: 1)
        self.descriptionLabel?.text = "￥21.00"
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
